%this function gives you the linear indices of NaNs in a matrix

%created by Ricardo Mejia-Alvarez
%university of Illinois at Urbana-Champaign
%Urbana, Il. 09/21/2010

function U = GetRidofNaNs(U)

NaNplace = find( isnan( U ) == 1 );
L = length( NaNplace );

for k = 1 : L
    U( NaNplace( k ) ) = 0;
end

end